package eco2automotive.gui;
import java.awt.Dimension;
import eco2automotive.gui.components.Panel_DTCs;
import eco2automotive.gui.components.Panel_PROGRESS;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;
import javax.swing.*;
import java.awt.BorderLayout;

/**  
  * Show a modal dialog: diagnostic of trouble codes result.
  * @version 1.0
  * @autor Fco. Javier Sánchez Esparza
  * @see eco2automotive.gui.components.Panel_PROGRESS
  * @see eco2automotive.gui.components.Panel_DTCs
  *
  */ 
public class Layout_DTCs extends JDialog{
   Panel_DTCs PANEL_DTCS;
   private Panel_PROGRESS PANEL_PROGRESS;
   eco2automotive parent;    
    /** 
     * Create a new Panel_DTCs and a Panel_PRROGRESS
     * @param parent is the root JFrame
    */
  public Layout_DTCs(JFrame parent){
        super(parent);        
        setTitle("Diagnostic of Trouble Codes");     
        addWindowListener( new WindowAdapter() {
 public void windowClosing( WindowEvent e ) {
 dispose();
 }
 });        
        PANEL_DTCS=new Panel_DTCs();  
        PANEL_PROGRESS= new Panel_PROGRESS(1); 
        this.setLayout(new BorderLayout());
        this.add(PANEL_DTCS,BorderLayout.CENTER);                 
        this.add(PANEL_PROGRESS,BorderLayout.SOUTH);
        this.parent=(eco2automotive)parent;              
        setSize(new Dimension(400, 300));        
        setResizable(false);        
        pack();                           
    }
   /** 
     * Update the panel of information: Panel_PROGRESS
     * @see eco2automotive.gui.components.Panel_PROGRESS 
     * @param info String to display
    */
  public void updatePrgogress(String info){
    this.PANEL_PROGRESS.updateLabel("Query DTCs...... "+info);
    this.PANEL_PROGRESS.advance();
} 
  /** 
     * Display the result
     * @param info_errror , String contains the result.
    */
public void showInfoError(String info_error){
    this.PANEL_DTCS.updateInformation(info_error);
}
}
